<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>数据查看</title>
    <script type="text/javascript" src="../js/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="../js/page.js"></script>
    <link rel='stylesheet' type='text/css' media='screen' href='../css/page.css'> 
    <script>
        window.onload=function(){
            var table=document.getElementById("stutable");
            for(var i=0;i<table.rows.length;i++){
                table.rows[i].cells[0].innerHTML=(i+1);
            }
        }
    </script>
</head>
<body>
    <?php
        include_once 'DBLink.php';
        session_start();
        if($_SESSION['username']==null||$_SESSION['password']==null){
            header("refresh:0;url=../index.html");
        }
    ?>     
    <div class="bg bg-blur"></div>
    <div class="content">
        <?php include_once 'adminNavbar.php' ?>
        <div class="stuList">
            <div class="cur-position">
                首页<span class="seperate-lean">/</span><span style="color: #000;">数据查看</span>
            </div>
            <form class="search" action="userAction.php?method=search" method="post">
                <input type="text" name="time" placeholder="请输入时间">
                <button class="button_search" type="submit">
                    <i><img src="../images/search.png"></img></i><span>搜  索</span>
                </button>
            </form>
            <table class="stutable">
                <thead >
                    <tr>
			<th>序号</th><th>时间</th>
                        <th>时间</th><th>温度</th>
                        <th>烟雾</th><th>操作</th>
                    </tr>
                </thead>
                <tbody id="stutable">
                    <?php                        
                        $dblink=new DBLink();
                        $conn=$dblink->getConnect();
                        $sql="SELECT *  FROM fire order by time DESC";
                        $result=$dblink->query($sql,$conn);
			while($row=mysqli_fetch_assoc($result)){
				if($row['smoke'] == 1)
					$smoke = "有烟雾";
				else
					$smoke = "无烟雾"
?>
			<tr>
			    <td></td>
			    <td><?php echo $row['time'];?></td>
			    <td><?php echo $date=date("Y-m-d H:i:s",$row['time']);?></td>
			    <td><?php echo $row['temperature']; ?></td>
			    <td><?php echo $smoke; ?></td>
			    <td>
				<a href="userAction.php?method=delete&time=<?php echo $row['time']; ?>">
				    <button class="button_delete" >
					<i><img src="../images/delete.png"></img></i><span>删除</span>
				    </button>                               
				</a>
			    </td>
                        </tr>
                    <?php
                        }
                        $dblink->close($conn);
                    ?>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>
